package com.filter;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class FilterIllegalityString {
    public boolean IllegaListyString(String name){
        List<String> list=new ArrayList();
        InputStream resourceAsStream = FilterIllegalityString.class.getClassLoader().getResourceAsStream("illegality.txt");
        InputStreamReader inputStreamReader=null;
        try {
             inputStreamReader = new InputStreamReader(resourceAsStream, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        BufferedReader bufferedReader=new BufferedReader(inputStreamReader);
        String line=null;
        while (true){
            try {
                if (!((line=bufferedReader.readLine())!=null)) break;
            } catch (IOException e) {
                e.printStackTrace();
            }
            list.add(line);
            System.out.println(line);
        }
        for (String s : list) {
            if(name.contains(s))
                return false;
        }
        return true;
    }

    public static void main(String[] args) {
        FilterIllegalityString filterIllegalityString = new FilterIllegalityString();
        boolean aa = filterIllegalityString.IllegaListyString("傻");
        if(aa){
            System.out.println("校验成功");
        }else{
            System.out.println("校验失败");
        }
    }
}
